package io.filterstream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class BufferedStreamCopier {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		copy(System.in, System.out);
	}

	public static void copy(InputStream in, OutputStream out)
			throws IOException {
		BufferedInputStream bin = new BufferedInputStream(in);
		BufferedOutputStream bout = new BufferedOutputStream(out);
		while (true) {
			int datum = bin.read();
			if (datum == -1) {
				break;
			}
			bout.write(datum);
		}
		bout.flush();
		bin.close();
		bout.close();
	}

}
